package com.gblfy.order.controller;

import com.gblfy.api.RemoteProductService;
import com.gblfy.api.RemoteShopCartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "订单服务入口")
@RestController
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class OrderController {

    private final RemoteProductService productService;
    private final RemoteShopCartService shopCartService;

    @GetMapping("/getDubboHello")
    public String getDubboHello(@RequestParam("name") String name) {
        String dubboHello = shopCartService.getDubboHello(name);
        return dubboHello;
    }

    @ApiOperation(value = "通过商品ID获取商品名称", notes = "")
    @GetMapping("/order")
    public String getProductNameByproductId(@RequestParam Integer productId) {
        // 调用商品服务，通过商品ID获取商品名称
        String productName = productService.getProductName(productId);
        return "商品名称:" + productName;
    }

    @GetMapping("/order/user")
    public String getOrderByUserId(@RequestParam Integer userId) {
        return "用户ID:【" + userId + "】的订单号是666666";
    }

}
